import request from '@/utils/request'
import * as mock from './mock/dividend'

const isMock = import.meta.env.VITE_API_MOCK === 'true'

/**
 * 获取分红池信息
 * @returns {Promise}
 */
export function getDividendPoolInfo() {
  if (isMock) {
    return Promise.resolve(mock.getDividendPoolInfo())
  }
  return request({
    url: '/dividend/pool/info',
    method: 'get'
  })
}

/**
 * 分红排名
 * @returns {Promise}
 */
export function poolRank(param) {
  return request({
    url: '/dividend/pool/rank',
    method: 'get',
    params: param
  })
}

/**
 * 获取用户分红信息
 * @returns {Promise}
 */
// export function getUserDividendInfo() {
//   if (isMock) {
//     return Promise.resolve(mock.getUserDividendInfo())
//   }
//   return request({
//     url: '/dividend/user/info',
//     method: 'get'
//   })
// }

/**
 * 参与分红池
 * @param {Object} data 参与数据
 * @returns {Promise}
 */
export function joinDividendPool(data) {
  if (isMock) {
    return Promise.resolve(mock.joinDividendPool(data))
  }
  return request({
    url: '/dividend/pool/join',
    method: 'post',
    data
  })
}